/**
 * @对登入页面的form验证进行分离
 * @大大提高页面的维护性
 *
 */
var validatePasswordVerification = (rule, value, callback) => {
    if(!value || value.length !==5){
        callback("验证码不符合规范")
    }else{
        callback();
    }
};
var validateUsername = (rule, value, callback) => {
    //用户名正则，4到16位（字母，数字，下划线，减号）
    var uPattern = /^[a-zA-Z0-9_-]{3,16}$/;
    // console.log(uPattern.test(value))
    if (uPattern.test(value)) {
        callback();
    } else {
        callback("3到16位字母数字下划线减号")
    }
};
var validatePassword = (rule, value, callback) => {
    var uPattern = /^[a-zA-Z0-9_-]{3,16}$/;
    if (uPattern.test(value)) {
        callback();
    } else {
        callback("3到16位字母数字下划线减号")
    }
};

export default {
    data() {
        return {
            rulesLogin: {
                username: [
                    { validator: validateUsername, trigger: 'blur' }
                ],
                password: [
                    { validator: validatePassword, trigger: 'blur' }
                ],
                verification: [
                    { validator: validatePasswordVerification, trigger: 'blur' }
                ]
            }
        }
    }
}
